package name.matthewgreet.example3.action; import org.apache.struts2.convention.annotation.Action; import org.apache.struts2.convention.annotation.InterceptorRef; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import com.opensymphony.xwork2.ActionSupport; import name.matthewgreet.example3.common.AbstractFormDrivenActionSupport; import name.matthewgreet.example3.common.BrowserTabSession; import name.matthewgreet.example3.common.ListCache; import name.matthewgreet.example3.common.NullForm; import name.matthewgreet.example3.vo.CountryList; import name.matthewgreet.example3.vo.CountryDTO; /** * Deletes country. */ @InterceptorRef("FormDrivenStack") @Results({ @Result(name=ActionSupport.INPUT, type="redirectAction", params = {"namespace", "/", "actionName", "ViewCountry"}), @Result(name=ActionSupport.SUCCESS, type="redirectAction", params = {"namespace", "/", "actionName", "ViewCountryList"}) }) public class RemoveCountryAction extends AbstractFormDrivenActionSupport<NullForm> { private static final long serialVersionUID = -700627736127116372L; public RemoveCountryAction() { super(); } @Action("/RemoveCountry") @Override public String execute() throws Exception { CountryDTO country; BrowserTabSession browserTabSession; ListCache<Integer,CountryDTO> listCache; browserTabSession = getBrowserTabSession(); listCache = ViewCountryListAction.retrieveListCache(browserTabSession); country = listCache.getSelected(); listCache.removeSelected(); CountryList.getInstance(browserTabSession).removeCountry(country.getId()); addActionMessage(country.getName() + " removed"); return ActionSupport.SUCCESS; } @Override protected NullForm makeForm() { return new NullForm(); } }